PostgreSQL类型转换函数 to | 您所在的位置:网站首页 › to number函数 › PostgreSQL类型转换函数 to |
PostgreSQL类型转换函数 to_char( ***, text), to_number(***,text)
PostgreSQL类型转换函数将数值转成字符串类型将字符串转成数值
其他转换Function
PostgreSQL类型转换函数
将数值转成字符串类型
调用to_char(int, text)函数,int为要转换值,text为数值格式化模式 模式描述9带有指定数值位数的值0带前导零的值.(句点)小数点,(逗号)分组(千)分隔符PR尖括号内负值S带符号的数值L货币符号D小数点G分组分隔符MI在指明的位置的负号(如果数字 < 0)PL在指明的位置的正号(如果数字 > 0)SG在指明的位置的正/负号 eg SELECT to_char(12345, '9999999999999999999') //结果‘ 12345’,结果字符串前面有空格,位数跟格式化模式中9的位数有关; SELECT to_char(12345, '99999') //结果‘12345’ SELECT to_char(12345, '9999') //结果‘####’,当模式串小于数字个数时,字符串会显示为#,位数跟格式化模式中9的位数有关; 将字符串转成数值方法调用: to_number(text,text)函数,参数1是要转的数字字符串,参数2为模式参数 其他转换Function FunctionReturnTypeDescriptionExampleto_char(timestamp, text)textconverttimestamptostringto_char(current_timestamp,‘HH12:MI:SS’)to_char(interval, text)textconvertintervaltostringto_char(interval’15h022m0212s’,‘HH24:MI:SS’)to_char(int, text)textconvertintegertostringto_char(404,‘999’)to_char(double precision, text)textconvertreal/double precisiontostringto_char(404.8::real,‘999D9’)to_char(numeric, text)textconvertnumerictostringto_char(-404.8,‘999D99S’)to_date(text, text)dateconvertstringtodateto_date(‘0502Dec022000’,‘DD02Mon02YYYY’)to_number(text, text)numericconvertstringtonumericto_number(‘12,454.8-’,‘99G999D9S’)to_timestamp(text, text)timestampwithtimezoneconvertstringtotimestampto_timestamp(‘0502Dec022000’,‘DD02Mon02YYYY’)to_timestamp(double precision)timestampwithtimezoneconvertUnixepochtotimestampto_timestamp(1284352323) |
CopyRight 2018-2019 实验室设备网 版权所有 |